<template>
  <a-card>
    <a-descriptions bordered size="small">
      <a-descriptions-item v-for="(item,index) in formData" :key="index" :label="item.label">{{
          item.dictCode ? transformDataByDict(item.dictCode, item.content) :item.content
        }}
      </a-descriptions-item>
    </a-descriptions>
  </a-card>
</template>

<script>
import {getAction} from "@api/manage";
import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'

export default {
  name: "HfPmImplementationBasicInfo",
  data() {
    return {
      formData: [
        {label: "合同名称", field: "name", content: ""},
        {label: "项目编号", field: "code", content: ""},
        {label: "合同编号", field: "numCode", content: ""},
        {label: "项目简称", field: "shortName", content: ""},
        {label: "项目经理", field: "charger", content: ""},
        {label: "签订日期", field: "signDate", content: ""},
        {label: "项目分类", field: "type", content: "", dictCode: 'icm_project_type'},
        {label: "项目状态", field: "projectState", content: "", dictCode: 'hf_project_states'},
        {label: "项目周期/周", field: "projectCycle", content: ""},
        {label: "开发人天", field: "estimateWorkday", content: ""},
        {label: "实施人天", field: "actualWorkday", content: ""},
        {label: "完工比例", field: "actualPersonDay", content: ""},
        {label: "计划开始时间", field: "planStartTime", content: ""},
        {label: "计划结束时间", field: "planEndTime", content: ""},
        {label: "验收日期", field: "checkTime", content: ""},
        {label: "实际回款", field: "actualMoney", content: ""},
        {label: "合同金额", field: "money", content: ""},
        {label: "回款比例", field: "ratioMoney", content: ""},
        {label: "总计报销", field: "totalReimbursement", content: "",isFixed:true},
        {label: "延期天数", field: "delayDays", content: ""},
        {label: "项目得分", field: "projectScore", content: ""},

      ],
      url: {
        queryById: '/pm/pmProject/queryById'
      }
    }
  },
  props: {
    selectedKeys: {
      type: [Array, String],
    }
  },
  watch: {
    selectedKeys: {
      immediate: true,
      handler(val) {
        if (val.length > 0) {
          this.getBasicInfo(val.toString())
        }
      },
    },
  },
  created() {
  },
  methods: {
    transformDataByDict(dictCode, key) {
      return filterDictTextByCache(dictCode, key)
    },
    getBasicInfo(id) {
      getAction(this.url.queryById, {id}).then(res => {
        if (res.success) {
          for (let key in res.result) {
            this.formData.forEach(item => {
              if (key === item.field) {
                item.content = res.result[key]
              }
              if(item.field === 'estimateWorkday'){
                item.content = res.result['projectWorkHours']+ '/' + res.result[item.field]
                // if (res.result['projectWorkHours']>res.result[item.field]){
                //   item.content.css("color:red")
                // }
              }
              if(item.field === 'actualWorkday'){
                item.content = res.result['projectWorkHoursCharger']+ '/' + res.result[item.field]
                // if (res.result['projectWorkHoursCharger']>res.result[item.field]){
                //   item.content.css("color:red")
                // }
              }
            })
          }
        }
      })
    },
  }
}
</script>

<style scoped lang="less">
/deep/ .ant-descriptions-item-label {
  width: 150px;
}
</style>